package com.qingfeng.medical.controller.admin.infomation;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qingfeng.medical.base.controller.BaseController;
import com.qingfeng.medical.base.log.annotation.Log;
import com.qingfeng.medical.base.log.enums.BusinessType;
import com.qingfeng.medical.base.result.Result;
import com.qingfeng.medical.biz.information.domain.entity.Patient;
import com.qingfeng.medical.biz.information.domain.entity.UserInfo;
import com.qingfeng.medical.biz.information.domain.vo.UserInfoPageVo;
import com.qingfeng.medical.biz.information.service.PatientService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;


/**
 * 就诊人表
 *
 * @author 清风学Java
 * @date 2023-04-27 16:26:12
 */
@Api(tags = "就诊人表管理")
@RestController
@RequestMapping("/admin/info/patient")
@Validated
public class PatientController extends BaseController {

    @Autowired
    private PatientService patientService;

    @ApiOperation(value = "分页查询就诊人信息", notes = "分页查询就诊人信息")
    @GetMapping("/list")
    @Log(title = "就诊人管理", businessType = BusinessType.SELECT, message = "分页查询就诊人信息")
    public Result<UserInfoPageVo> patientList(
            @ApiParam(name = "page", value = "当前页码", required = true)
            @RequestParam("page") Long page,
            @ApiParam(name = "limit", value = "每页记录数", required = true)
            @RequestParam("limit") Long limit,
            @ApiParam(name = "certificatesType", value = "证件类型", required = false)
            @RequestParam("certificatesType") String certificatesType,
            @ApiParam(name = "authStatus", value = "认证状态", required = false)
            @RequestParam("authStatus") Integer authStatus,
            @ApiParam(name = "patientStatus", value = "就诊人状态", required = false)
            @RequestParam("patientStatus") Integer patientStatus) {
        UserInfoPageVo userInfoPageVo = patientService.patientList(
                new Page<UserInfo>(page, limit),
                certificatesType,
                authStatus,
                patientStatus
        );
        return Result.ok(userInfoPageVo);
    }

    @ApiOperation(value = "就诊人认证", notes = "就诊人认证")
    @PutMapping("/auth")
    @Log(title = "就诊人管理", businessType = BusinessType.UPDATE, message = "就诊人认证")
    public Result authPatient(@RequestBody Patient patient){
        patientService.authPatient(patient);
        return Result.ok();
    }
}
